﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
using Assisticant.Collections;
using Assisticant.Fields;

namespace UGD.Models
{
    public class Item
    {
        private Observable<string> _name = new Observable<string>();
        private ObservableList<Duty> _duty = new ObservableList<Duty>();
        private Observable<bool> _showChart = new Observable<bool>(true);
        public string Name
        {
            get
            {
                return _name.Value;
            }
            set
            {
                _name.Value = value;
            }
        }
        public IEnumerable<Duty> Duty => _duty.ToList();

        public void AddDuty(Duty duty)
        {
            _duty.Add(duty);
        }

        public DateTime RangeStart
        {
            get
            {
                return _duty.OrderBy(o => o.Start).First().Start;
            }
        }
        public DateTime RangeEnd
        {
            get
            {
                return _duty.OrderBy(o => o.End).Last().End;
            }
        }

        public long Ticks
        {
            get
            {
                var result =    _duty.Sum(o => o.Ticks);

                return result;
            }
        }

        public bool ShowChart { get { return _showChart.Value; } set { _showChart.Value = value; } }
    }




}
